var t = function(t) {
    return (t = t.toString())[1] ? t : "0" + t;
}, e = function(e) {
    return [ (e = new Date()).getFullYear(), e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1, e.getDate() < 10 ? "0" + e.getDate() : e.getDate() ].map(t).join("-");
};

module.exports = {
    formatTime: function(e) {
        var n = (e = new Date()).getFullYear(), r = e.getMonth() + 1, a = e.getDate(), u = e.getHours(), s = e.getMinutes(), g = e.getSeconds();
        return [ n, r, a ].map(t).join("/") + " " + [ u, s, g ].map(t).join(":");
    },
    GetDateStr: e,
    GetDateStrAddDay: function(t) {
        var n = new Date(), r = new Date();
        return r.setDate(n.getDate() + t), e(r);
    },
    GetAge: function(t) {
        var e = (t + "").length;
        if (0 == e) return 0;
        if (15 != e && 18 != e) return 0;
        var n = "";
        18 == e && (n = t.substr(6, 4) + "/" + t.substr(10, 2) + "/" + t.substr(12, 2)), 
        15 == e && (n = "19" + t.substr(6, 2) + "/" + t.substr(8, 2) + "/" + t.substr(10, 2));
        var r = new Date(n), a = new Date(), u = a.getFullYear() - r.getFullYear();
        return (a.getMonth() < r.getMonth() || a.getMonth() == r.getMonth() && a.getDate() < r.getDate()) && u--, 
        u;
    },
    timerRange: function(t, e, n) {
        var r = t.split(":");
        if (2 != r.length) return !1;
        var a = e.split(":");
        if (2 != a.length) return !1;
        var u = n.split(":");
        if (2 != a.length) return !1;
        var s = new Date(), g = new Date(), i = new Date();
        return s.setHours(r[0]), s.setMinutes(r[1]), g.setHours(a[0]), g.setMinutes(a[1]), 
        i.setHours(u[0]), i.setMinutes(u[1]), i.getTime() - s.getTime() > 0 && i.getTime() - g.getTime() < 0;
    }
};